<?php

/**
 * Turno form.
 *
 * @package    SistemaRutasEc
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class TurnoForm extends BaseTurnoForm
{
	public function configure()
	{
		$this->widgetSchema['id_co'] = new sfWidgetFormInputHidden();
		$this->widgetSchema['id_fre'] = new sfWidgetFormChoice(array('choices' => array('' => 'Seleccione una ruta')));
		$this->widgetSchema['id_ru'] = new sfWidgetFormDoctrineChoice(array('model' => 'Ruta', 'add_empty' => 'Seleccione una ruta'));

		if ($this->getObject())
		{
			$q = Doctrine_Core::getTable('Ruta')
			->createQuery('r')
			->where('r.id_co = ?', $this->getObject()->id_co)
			->andWhere('r.activo = true');

			$this->widgetSchema['id_ru']->setOption('query', $q);
		}

		$this->widgetSchema['id_co']->setAttribute('id', 'cooperativa');
		$this->widgetSchema['id_fre']->setAttribute('id', 'frecuencia');
		$this->widgetSchema['id_ru']->setAttribute('id', 'ruta');
  	}
}
